﻿using log4net;
using System;

namespace BlazorAdmin.Logs
{
    public class LogUtil
    {
        private static ILog MainLog = LogManager.GetLogger("Main");
        private static ILog ErrLog = LogManager.GetLogger("ERROR");

        static LogUtil()
        {
            log4net.Config.XmlConfigurator.Configure();
        }

        /// <summary>
        /// 记录日志
        /// </summary>
        /// <param name="info">日志消息</param>
        public static void Info(string info)
        {
            MainLog.Info(info);
        }

        /// <summary>
        /// 记录调试日志
        /// </summary>
        /// <param name="debug">调试消息</param>
        public static void Debug(string debug)
        {
            MainLog.Debug(debug);
        }

        // <summary>
        /// 记录告警日志
        /// </summary>
        /// <param name="warn">警告消息</param>
        public static void Warn(string warn)
        {
            MainLog.Warn(warn);
        }

        /// <summary>
        /// 记录错误日志
        /// </summary>
        /// <param name="error">错误消息</param>
        public static void Error(string error)
        {
            ErrLog.Error(error);
        }

        /// <summary>
        /// 记录错误日志
        /// </summary>
        /// <param name="error">错误消息</param>
        /// <param name="ex">异常对象</param>
        public static void Error(string error, Exception ex)
        {
            ErrLog.Error(error, ex);
        }

        /// <summary>
        /// 记录失败日志
        /// </summary>
        /// <param name="fatal">失败消息</param>
        public static void Fatal(string fatal)
        {
            ErrLog.Fatal(fatal);
        }
    }
}
